#include "queue.h"
#include "stdio.h"

/**
 * @brief Main function to demonstrate the queue functionality
 * 
 * This function creates a queue, adds some messages, retrieves and prints messages.
 * 
 * @return int Exit status
 */
int main() {
    queue_t *q = queue_create(3, sizeof(int));
    if (!q) {
        return -1;
    }


    int data1 = 1, data2 = 2, data3 = 3, data4 = 4, data5 = 5;
    for (int i = 0; i < 10; i++){
		queue_send(q, &data1);
	}
	queue_print(q);
	queue_send(q, &data1);
    queue_send(q, &data2);
    queue_send(q, &data3);
	queue_print(q);
    queue_send_cover(q, &data4);
    queue_send_cover(q, &data5);
    queue_print(q);

    int *data_read;
    int message_size = queue_size(q);
    printf("remain size %d: ", message_size);
    while (message_size > 0 && message_size--) {
        queue_receive(q, (void **)&data_read);
        printf("%d ", *data_read);
    }
    printf("\n");

    queue_print(q);
    return 0;
}